/*
 * MyColumnCellEditor.java
 * Copyright 2010 Universidad Francisco de Paula Santander (UFPS).
 * Todos los Derechos Reservados.
 * Creado el 18/04/2010, 11:31:30 PM
 */


package com.ufps.cuatro.util.editor;

import com.ufps.cuatro.modelo.representacion.componente.ComponenteDistribuidor;
import java.awt.Component;
import java.util.ArrayList;

import javax.swing.AbstractCellEditor;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

/**
 * <i><b>MyColumnCellEditor:</b></i> @DescripcionClase
 * @author Carlos A. Torres C. - Dolly E. Guerrero. <https://code.google.com/p/tesis4dor/>
 * @version 1.0 18/04/2010
 * @see AbstractCellEditor
 * @see TableCellEditor
 */
public class MyColumnCellComboBoxEditor extends AbstractCellEditor implements TableCellEditor{
    private static final long serialVersionUID = -3362230132643168613L;        
    
    private Object obj;
    private Object[] objItems;

    /**
     * @DescripcionMetodo
     */
    public MyColumnCellComboBoxEditor(Object[] objItems) {
        this.objItems = objItems;
    }    

    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {               
      try{
        this.obj = value;
        if(value instanceof ComponenteDistribuidor){
            ComponenteDistribuidor objComponenteDistribuidor = (ComponenteDistribuidor) value;
            return new MyComboBoxEditor(objItems, objComponenteDistribuidor);
        }
        return new JLabel(String.valueOf(value));
    }catch(java.lang.NullPointerException ex){}
      return null;
    }

    public Object getCellEditorValue() {
       try{
        return this.obj;
    }catch(java.lang.NullPointerException ex){}
       return null;
    }
}
